import React,{Suspense,lazy} from 'react'
import {BrowserRouter as Router , HashRouter as Hash,Redirect,Route,Switch} from "react-router-dom"
import LazyLoading from '../components/Loading'

export default function MainView() {
    return (
       <div >
            <Hash>
            <Route component={MainLayout}></Route>
        </Hash>
       </div>
    )
}


function MainLayout(){
    return (
           <Suspense fallback={LazyLoading()}>
                 <Switch>
                <Route path='/' exact render={()=>(<Redirect to='./login'/>)}></Route>
                <Route path="/login" component={lazy(()=>import('./login/login'))} />
                <Route path="/register" component={lazy(()=>import('./login/register'))} />
                <Route path="/forgetpass" component={lazy(()=>import('./login/forgetpass'))} />

                <Route path="/main" component={lazy(()=>import('./main/index'))} />
                <Route path="/404"  component={lazy(()=>import('./errorpage/404'))} />
                <Route path="/503" component={lazy(()=>import('./errorpage/503'))} />
                {/* <Route path='/list' component={lazy(()=>import('./student/stulist'))}></Route> */}
                 <Route path='/add' component={lazy(()=>import('./user/add'))}></Route>
                 <Route path='/fenxi' component={lazy(()=>import('./user/fenxi'))}></Route>


                 {/* 报修 */}
                 {/* <Route path='/reports' component={lazy(()=>import('./reports/'))}></Route> */}

                
                <Route render={()=>(<Redirect to='./404'/>)}></Route>

            </Switch>
            </Suspense>
    )
}
